package com.itbupt.trigger.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Author dingchang
 * @Date 2025/5/5 20:56
 * @Description: 监听 结算完成的 消息
 */

@Slf4j
@Component
public class TeamSuccessTopicListener {

    /**
     * RabbitListener - 声明一个消息监听器，它会监听指定的队列，并在队列中有消息时触发对应的方法
     * @param message
     * exchange - 主题交换机会根据路由键的模式匹配规则将消息路由到队列
     */
    @RabbitListener(
            bindings = @QueueBinding(
                    value = @Queue(value = "${spring.rabbitmq.config.producer.topic_team_success.queue}"),
                    exchange = @Exchange(value = "${spring.rabbitmq.config.producer.exchange}", type = ExchangeTypes.TOPIC),
                    key = "${spring.rabbitmq.config.producer.topic_team_success.routing_key}"
            )
    )
    public void listener(String message) {
        log.info("接收消息:{}", message);
    }

}
